import Vue from 'vue'
import Router from 'vue-router';


Vue.use(Router)

/**
 * 重写路由的push方法
 */
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(error => error)
}

/* Layout */
import Layout from '@/views/layout/Layout'
import prdLayout from '@/views/layout/prdLayout'

import Home from '@/views/index/index'
import product from '@/views/product/product'
import platform from '@/views/platform/platform'
import cart from '@/views/cart/cart'
import login from '@/views/login'
import order from '@/views/order/order'
import content from '@/views/content/content'
import joinus from '@/views/joinus/joinus'
import company from '@/views/company/company'
import detail from '@/views/product/detail/detail'
import isPlaced from '@/views/product/isPlaced/isPlaced'
import search from '@/views/search/search'
import news from '@/views/news/news'
import spr from '@/views/appSPR/appSPR'


export const constantRouterMap = [
  { path: '/', component: Layout, children: [
    { path: '/', component: Home, meta: { title: '首页' } }, 
    { path: '/platform', component: platform, meta: { title: '服务平台' } },
    { path: '/cart', component: cart, meta: { title: '购物车' } },
    { path: '/order', component: order, meta: { title: '订单' } },
    { path: '/content', component: content, meta: { title: '联系我们' } },
    { path: '/joinus', component: joinus, meta: { title: '加入我们' } },
    { path: '/company', component: company, meta: { title: '企业简介' } },
    { path: '/isPlaced', component: isPlaced, meta: { title: '下单成功' } },
    { path: '/search', component: search, meta: { title: '搜索' } },
    { path: '/news', component: news, meta: { title: '新闻' }, },{ path: '/spr', component: spr, meta: { title: 'spr' }, }
  ] },
    { path: '/login', component: login, meta: { title: '登录' } 
  },{ path: '/product', component: prdLayout,children: [
    { path: '/product', component: product, meta: { title: '产品订购' } },
    { path: '/detail/:id', component: detail, meta: { title: '详情' } }
  ] },
  ]

/* 初始路由 */
export default new Router({
    mode: 'history', //后端支持可开
    scrollBehavior(to, from, savedPosition) {
        return {
            x: 0,
            y: 0
        }
    },
    routes: constantRouterMap
})

export const asyncRouterMap = []



export const allRoutes = []